package com.pro01.apirednote.mapper;

import com.pro01.apirednote.pojo.ContentFile;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ContentFileMapper {

    // 发布内容
    @Insert("INSERT INTO content_files (content_id, file_url, file_type) " +
            "VALUES (#{contentId}, #{fileUrl}, #{fileType})")
    int insertContentFile(ContentFile file);

    // 修改内容
    @Delete("DELETE FROM content_files WHERE content_id = #{contentId}")
    int deleteByContentId(Long contentId);
    
    // 根据内容ID查询文件
    @Select("SELECT * FROM content_files WHERE content_id = #{contentId}")
    List<ContentFile> selectByContentId(Long contentId);

    @Select("SELECT file_url FROM content_files WHERE content_id = #{contentId}")
    List<String> selectFileUrlsByContentId(Long contentId);
}
